home *** CD-ROM | disk | FTP | other *** search
/ Comix Games / Comix Games.iso / waldo / waldo.exe / FINAL08.DXR / 00255.ls < prev    next >
Encoding:
Text File  |  1995-10-08  |  8.8 KB  |  321 lines

  1. global gSlowMachine, gFortuneFrame, gFortuneCategory, gFortuneTeller, gTokens, gTokenSprite, gOkaySprite, gFortuneCategorySprite, gMainMenuCursor, gNavigationCursor, gGeneralCursor, gForwardCursor, gBackwardCursor, gLeftCursor, gRightCursor, gScoreCursor, gAboutCursor, gHotCursor, gWaitCursor, gHot, gHotMask, cMainMenuCursor, cNavigationCursor, cGeneralCursor, cForwardCursor, cBackwardCursor, cLeftCursor, cRightCursor, cScoreCursor, cAboutCursor, cHotCursor, cWaitCursor, gBDropSprite, gDot, gMainBDropCast, gMainBDropPICT, gPupSound, gUserName, gBalloons, gBalloonsList
  2.  
  3. on startMovie
  4.   clearGlobals()
  5.   if the frame = 1 then
  6.     startMoviePrefs()
  7.   end if
  8.   setProp(1, 48, "visibility", 1)
  9.   set the volume of sound 1 to 255
  10.   set the volume of sound 2 to 255
  11.   set gHot to the number of cast "Hot"
  12.   set gHotMask to the number of cast "HotMask"
  13.   set gSlowMachine to the machineType = 256
  14.   set gOkaySprite to 47
  15.   set gFortuneCategorySprite to 25
  16.   set gFortuneTeller to label("Query")
  17.   set gTokens to 0
  18.   set gTokenSprite to 45
  19.   set gBDropSprite to 1
  20.   set gBalloons to 0
  21.   set gBalloonsList to [0, 0, 0, 0]
  22.   puppetSound(0)
  23.   defineHotSpots([0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0])
  24.   when keyDown then checkKey
  25. end
  26.  
  27. on stopMovie
  28.   set the text of cast "Query" to "?"
  29.   set the text of cast "Query2" to "?"
  30. end
  31.  
  32. on checkKey
  33.   set userKey to the key
  34.   set userKeyCode to the keyCode
  35.   if (userKey >= "0") and (userKey <= "9") then
  36.     if fortuneTeller() then
  37.       if the optionDown then
  38.         set the soundLevel to value(userKey)
  39.         dontPassEvent()
  40.         exit
  41.       else
  42.         if the castNum of sprite 19 = the number of cast "Query" then
  43.           appendText(userKey)
  44.           pass()
  45.           exit
  46.         end if
  47.       end if
  48.     else
  49.       set the soundLevel to value(userKey)
  50.       dontPassEvent()
  51.       exit
  52.     end if
  53.   end if
  54.   if fortuneTeller() then
  55.     if userKey = RETURN then
  56.       if the visible of sprite gOkaySprite = 1 then
  57.         dontPassEvent()
  58.         exit
  59.       else
  60.         if the frame >= label("Query") then
  61.           if pressButton(gOkaySprite - 1, 1) then
  62.             go("No Query")
  63.           end if
  64.           dontPassEvent()
  65.         else
  66.           pass()
  67.           exit
  68.         end if
  69.       end if
  70.     else
  71.       if the castNum of sprite 19 = the number of cast "Query" then
  72.         if (userKey >= "A") and (userKey <= "Z") then
  73.           appendText(userKey)
  74.           pass()
  75.           exit
  76.         end if
  77.         if (userKey = " ") or (userKey = "-") or (userKey = "/") or (userKey = ".") or (userKey = "!") or (userKey = "?") or (userKey = ":") or (userKey = ";") then
  78.           appendText(userKey)
  79.           pass()
  80.           exit
  81.         end if
  82.         if charToNum(userKey) = 8 then
  83.           deleteText(userKey)
  84.           pass()
  85.           exit
  86.         end if
  87.         dontPassEvent()
  88.       end if
  89.     end if
  90.   end if
  91. end
  92.  
  93. on appendText userKey
  94.   set gUserName to the text of cast "Query"
  95.   if the number of chars in gUserName < 30 then
  96.     set gUserName to gUserName & userKey
  97.     set the text of cast "Query" to gUserName
  98.     updateStage()
  99.   else
  100.   end if
  101. end
  102.  
  103. on deleteText userKey
  104.   if charToNum(userKey) = 8 then
  105.     set gUserName to the text of cast "Query"
  106.     delete char -30000 of gUserName
  107.     set the text of cast "Query" to gUserName
  108.     updateStage()
  109.   end if
  110. end
  111.  
  112. on programmersKey
  113.   return the shiftDown and the controlDown
  114. end
  115.  
  116. on fortuneTeller
  117.   return (the frame >= label("Query")) and (the frame < label("No Query"))
  118. end
  119.  
  120. on delayFor howLong, interrupt
  121.   set howLong to howLong + the timer
  122.   if voidp(interrupt) then
  123.     repeat while the timer < howLong
  124.       nothing()
  125.     end repeat
  126.   else
  127.     repeat while (the timer < howLong) and the mouseUp
  128.       nothing()
  129.     end repeat
  130.     if interrupt > 0 then
  131.       puppetTransition(0)
  132.       go(interrupt)
  133.     end if
  134.   end if
  135. end
  136.  
  137. on checkRange originalNumber, minValue, maxValue
  138.   if originalNumber < minValue then
  139.     set originalNumber to minValue
  140.   else
  141.     if originalNumber > maxValue then
  142.       set originalNumber to maxValue
  143.     end if
  144.   end if
  145.   return originalNumber
  146. end
  147.  
  148. on setProp startSprite, stopSprite, whichProperty, whichValue
  149.   repeat with x = startSprite to stopSprite
  150.     do("set the " & whichProperty & " of sprite x=whichValue")
  151.   end repeat
  152. end
  153.  
  154. on legalButton whichSprite
  155.   repeat while the mouseDown
  156.     nothing()
  157.   end repeat
  158.   return 1
  159. end
  160.  
  161. on invertButton whichSprite
  162.   puppetTransition(0)
  163.   set oldInk to the ink of sprite whichSprite
  164.   set the ink of sprite whichSprite to 4
  165.   updateStage()
  166.   delayFor(20)
  167.   repeat while the stillDown
  168.     if rollOver(whichSprite) then
  169.       set the ink of sprite whichSprite to 4
  170.     else
  171.       set the ink of sprite whichSprite to oldInk
  172.     end if
  173.     updateStage()
  174.   end repeat
  175.   if the ink of sprite whichSprite = oldInk then
  176.     return 0
  177.     exit
  178.   end if
  179.   set the ink of sprite whichSprite to oldInk
  180.   return 1
  181. end
  182.  
  183. on pressButton whichSprite, ignoreRollOver
  184.   set the loc of sprite whichSprite to point(the locH of sprite whichSprite + 1, the locV of sprite whichSprite + 1)
  185.   updateStage()
  186.   set the loc of sprite whichSprite to point(the locH of sprite whichSprite + 1, the locV of sprite whichSprite + 1)
  187.   updateStage()
  188.   set delayFor to the timer + 20
  189.   repeat while the mouseDown or (the timer < delayFor)
  190.     nothing()
  191.   end repeat
  192.   if voidp(ignoreRollOver) then
  193.     set theResult to rollOver(whichSprite)
  194.   else
  195.     set theResult to ignoreRollOver
  196.   end if
  197.   set the loc of sprite whichSprite to point(the locH of sprite whichSprite - 1, the locV of sprite whichSprite - 1)
  198.   updateStage()
  199.   set the loc of sprite whichSprite to point(the locH of sprite whichSprite - 1, the locV of sprite whichSprite - 1)
  200.   updateStage()
  201.   return theResult
  202. end
  203.  
  204. on advanceFrame whichFrame, whichSound
  205.   setProp(1, 40, "puppet", 0)
  206.   setProp(41, 48, "puppet", 1)
  207.   if whichSound > 0 then
  208.     pupSound(whichSound)
  209.   else
  210.     pupSound(0)
  211.   end if
  212.   go(whichFrame)
  213. end
  214.  
  215. on setFortuneFrame
  216.   go("No Query")
  217. end
  218.  
  219. on defineHotSpots cuMainMenu, cuNavigation, cuGeneral, cuForward, cuBackward, cuLeft, cuRight, cuScore, cuAbout, cuHot, cuWait
  220.   set gMainMenuCursor to cuMainMenu
  221.   set gNavigationCursor to cuNavigation
  222.   set gGeneralCursor to cuGeneral
  223.   set gForwardCursor to cuForward
  224.   set gBackwardCursor to cuBackward
  225.   set gLeftCursor to cuLeft
  226.   set gRightCursor to cuRight
  227.   set gScoreCursor to cuScore
  228.   set gAboutCursor to cuAbout
  229.   set gHotCursor to cuHot
  230.   set gWaitCursor to cuWait
  231.   setProp(1, 48, "visibility", 1)
  232. end
  233.  
  234. on checkHotSpots
  235.   if checkHotSpot(gHotCursor, cHotCursor) then
  236.     cursor([gHot, gHotMask])
  237.     exit
  238.   end if
  239.   cursor(-1)
  240. end
  241.  
  242. on checkHotSpot whichSprites, whichCursor
  243.   set theResult to 0
  244.   set startSprite to getAt(whichSprites, 1)
  245.   set stopSprite to getAt(whichSprites, 2)
  246.   if startSprite > 0 then
  247.     repeat with x = stopSprite down to startSprite
  248.       if the type of sprite x > 0 then
  249.         if rollOver(x) then
  250.           set theResult to 1
  251.           exit repeat
  252.         end if
  253.       end if
  254.     end repeat
  255.   end if
  256.   return theResult
  257. end
  258.  
  259. on pupSound whichSound
  260.   if (gPupSound <> whichSound) or not (the soundBusy of 1) then
  261.     set gPupSound to whichSound
  262.     puppetSound(whichSound)
  263.   end if
  264. end
  265.  
  266. on playSound whichSound
  267.   set whichCast to the number of cast whichSound
  268.   if whichCast > 0 then
  269.     puppetSound(whichSound)
  270.     updateStage()
  271.     repeat while the soundBusy of 1
  272.       updateStage()
  273.     end repeat
  274.     puppetSound(0)
  275.   end if
  276. end
  277.  
  278. on find startFrame, endFrame, startCast, endCast
  279.   set findList to []
  280.   put RETURN & "Results, sorted by frame:"
  281.   repeat with x = startFrame to endFrame
  282.     go(x)
  283.     repeat with y = 1 to 48
  284.       if the type of sprite y > 0 then
  285.         repeat with z = startCast to endCast
  286.           if the castNum of sprite y = z then
  287.             put "Frame " & x & ", channel " & y & " contains cast number " & z & "."
  288.             append(findList, [x, y, z])
  289.           end if
  290.         end repeat
  291.       end if
  292.     end repeat
  293.   end repeat
  294.   put RETURN & "Results, sorted by channel:"
  295.   repeat with x = 1 to 48
  296.     repeat with y = 1 to count(findList)
  297.       set dataCell to getAt(findList, y)
  298.       set whichChannel to getAt(dataCell, 2)
  299.       if whichChannel = x then
  300.         set whichFrame to getAt(dataCell, 1)
  301.         set whichCast to getAt(dataCell, 3)
  302.         put "Frame " & whichFrame & ", channel " & whichChannel & " contains cast number " & whichCast & "."
  303.       end if
  304.     end repeat
  305.   end repeat
  306.   put RETURN & "Results, sorted by cast:"
  307.   repeat with x = startCast to endCast
  308.     repeat with y = 1 to count(findList)
  309.       set dataCell to getAt(findList, y)
  310.       set whichCast to getAt(dataCell, 3)
  311.       if whichCast = x then
  312.         set whichFrame to getAt(dataCell, 1)
  313.         set whichChannel to getAt(dataCell, 2)
  314.         put "Frame " & whichFrame & ", channel " & whichChannel & " contains cast number " & whichCast & "."
  315.       end if
  316.     end repeat
  317.   end repeat
  318.   put "Done."
  319.   beep()
  320. end
  321.